<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>面试计划添加</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<form method="post" class="layui-form" action="">
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">部门</label>
      <div class="layui-input-inline">
        <select name="demandid" class="layui-input" id="deman" >
          <option value="-1">全部部门</option>
          <option th:each="d:${demands}" th:value="${d.id}" th:text="${d.departmentname.name}"></option>
        </select>
      </div>
      <label type="text" style="color: red;display:none;" id="demandid">请选择部门</label>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">姓名</label>
      <div class="layui-input-inline">
        <input type="text" class="layui-input" name="hxname">
      </div>
      <label type="text" style="color: red;display:none;" id="hxname">请输入姓名</label>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">手机号</label>
      <div class="layui-input-inline">
        <input name="hxphone" type="text" class="layui-input">
      </div>
      <label type="text" style="color: red;display:none;" id="hxphone">请输入手机号</label>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">工作年限</label>
      <div class="layui-input-inline">
        <input name="limit" type="number" max="50" min="1" class="layui-input">
      </div>
      <label type="text" style="color: red;display:none;" id="limit">请输入年限</label>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">学历</label>
      <div class="layui-input-inline">
        <select name="degree" class="layui-input">
          <option value="-1">请选择学历</option>
          <option value="大专">大专</option>
          <option value="本科">本科</option>
        </select>
      </div>
      <label type="text" style="color: red;display:none;" id="degree">请输入学历</label>
    </div>
    <br/>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">添加</button>
    </div>
  </div>
</form>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>


  layui.use(['form'], function () {
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.jquery;
    $("#deman").next().find("dl dd").click(function (){
      $("#demandid").hide();
    })
    $(":input[name='hxname']").click(function (){
      $("#hxname").hide();
    })
    $(":input[name='hxphone']").click(function (){
      $("#hxphone").hide();
    })
    $(":input[name='degree']").click(function (){
      $("#degree").hide();
    })
    $(":input[name='limit']").click(function (){
      $("#limit").hide();
    })
    //监听提交
    form.on('submit(saveBtn)', function (data) {

      let demandid=$(":input[name='demandid']").val();
      if (demandid<0){
        $("#demandid").show();
        return false;
      }


      let hxname=$(":input[name='hxname']").val();
      if (hxname==null || hxname==""){
        $("#hxname").show();
        return false;
      }


      let hxphone=$(":input[name='hxphone']").val();
      if (hxphone==null || hxphone==""){
        $("#hxphone").show();
        return false;
      }


      let degree=$(":input[name='degree']").val();
      if (degree<0){
        $("#degree").show();
        return false;
      }


      let limit=$(":input[name='limit']").val();
      if (limit<0 || limit>50){
        $("#limit").show();
        return false;
      }


      $.post('/interview/insertsp',data.field,function(res){
        if(res.data==="success"){
          var iframeIndex = parent.layer.getFrameIndex(window.name);
          parent.layer.close(iframeIndex);
          parent.layui.table.reload('table-user');
          parent.layer.msg(res.msg);
        }
      })
      return false;
    });
  });
</script>
</body>
</html>